/*
 * Copyright 2006 Abdulla G. Abdurakhmanov (abdulla.abdurakhmanov@gmail.com).
 * 
 * Licensed under the GPL, Version 2 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.gnu.org/copyleft/gpl.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * With any your questions welcome to my e-mail 
 * or blog at http://abdulla-a.blogspot.com.
 */

package org.ofsm.creator;

import org.jgraph.graph.DefaultGraphCell;

import org.ofsm.impl.FileFiniteStateMachineBaseModel;
import org.ofsm.impl.FileFiniteStateMachineModel;

public class StateGraphCell extends DefaultGraphCell{
    public StateGraphCell(FileFiniteStateMachineModel.StateInfo stateInfo) {
        userObject = stateInfo;
    }
    
    public void setUserObject(Object obj) {
        if(userObject instanceof FileFiniteStateMachineModel.StateInfo) {
            if( !(obj instanceof FileFiniteStateMachineModel.StateInfo))  {
                FileFiniteStateMachineModel.StateInfo stateInfo  = (FileFiniteStateMachineModel.StateInfo)userObject;
                stateInfo.getState().setName(obj.toString());
            }
        }
    }
    
    public FileFiniteStateMachineModel.StateInfo getStateInfo() {
        if(userObject instanceof FileFiniteStateMachineModel.StateInfo)
            return (FileFiniteStateMachineModel.StateInfo) userObject;
        else
            return null;
    }
}
